package com.exltsoft.fc.action.admin.useradmin;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import com.exltsoft.fc.action.CrudActionSupport;
import com.exltsoft.fc.entity.admin.User;

@Transactional
@SuppressWarnings("serial")
public class UserAction extends CrudActionSupport<User> {
	private UserDao userDao;
	
	private Long id;
	private User entity;
	private List<Map<String,Object>> list;
	
	public List<Map<String, Object>> getList() {
		return list;
	}

	public void setList(List<Map<String, Object>> list) {
		this.list = list;
	}

	public void setId(Long id) {
		this.id = id;
	}
	
	@Autowired
	public void setUserDao(UserDao userDao) {
		this.userDao = userDao;
	}

	public void prepareLogin() throws Exception {
		prepareModel();
	}
	
	public String login() throws Exception{
		prepareModel();
		System.out.println(entity.getUsrcode());
		entity = userDao.get(new Long(1));
		System.out.println("login");
		System.out.println(entity.getUsrcode());
		entity.getUsrpsw();
		return null;
	}

	@Override
	public String delete() throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String input() throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String list() throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	protected void prepareModel() throws Exception {
		if (id != null) {
			entity = userDao.get(id);
//			entity = securityEntityManager.getUser(id);
		} else {
			entity = new User();
		}
		
	}

	@Override
	public String save() throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public User getModel() {
		return entity;
	}

	public User getEntity() {
		return entity;
	}

	public void setEntity(User entity) {
		this.entity = entity;
	}	
}
